<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('reservation_logs', function (Blueprint $table) {
            $table->id();
            $table->dateTime("date");
            $table->string("phone");
            $table->string("name")->nullable();
            $table->string("time");
            $table->text("remark")->nullable();
            $table->unsignedBigInteger("user_id");
            $table->unsignedInteger("status")->default(0);
            $table->timestamps();
        });

        Schema::create('reservation_has_project', function (Blueprint $table) {
            $table->unsignedBigInteger('project_id');
            $table->unsignedBigInteger('reservation_id');

            $table->foreign('project_id')
                ->references("id")
                ->on("projects")
                ->cascadeOnDelete();
            $table->foreign('reservation_id')
                ->references("id")
                ->on("reservation_logs")
                ->cascadeOnDelete();

        });


    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('reservation_has_project');
        Schema::dropIfExists('reservation_logs');
    }
};
